<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2022/2/10 13:26
 * Desc:票务订单
 */
class Model_Provider_Api_Ticket_Order
{

    public static function get_api_model_by_order($order)
    {
        $partner_id = Model_Provider_Config::get_partner_id($order['supplierlist']);
        if(!$partner_id){
            return array('status' => false, 'msg' => 'not partner_id');
        }
        $interfaceCode = Model_Provider_Api_Ticket_Product::get_interface_code_by_ticket_id($order['suitid']);
        if ($interfaceCode) {
            $provider_channel = $interfaceCode['comeFrom'];
            // 初始化渠道订单类
            $provider_channel_order_model = Entities_Provider_Ticket_Order_Factory::getInstance($interfaceCode['comeFrom']);
            if (!$provider_channel_order_model) {
                return array('status' => false, 'msg' => 'not ticket provider channel order model');
            }
            $ticket_api = new Model_Provider_Api_Ticket($partner_id, $provider_channel);
            return array(
                'status' => true,
                'provider_channel_order_model' => $provider_channel_order_model,
                'ticket_api' => $ticket_api,
                'provider_product_id' => $interfaceCode['productId']
            );
        } else {
            return array('status' => false, 'msg' => 'not ticket');
        }
    }
}